<template>
	<view class="page"  :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
		<c-nav-bar :title="titleHeader" ></c-nav-bar>
		<view class="title">停车开票</view>
		<view v-for="(item,index) in list" :key="index" class="item" @tap="selectItem(item,index)">
			<view class="i_left">
				<image v-if="item.selected" src="https://i.ringzle.com/file/20231027/a21562a8f54a4fd094b43eaf8dd42ee6.png"></image>
				<image v-else src="https://i.ringzle.com/file/20231027/db588133d67548fc82dfb0d128eac9a8.png"></image>
				<view class="il_info">
					<view>{{item.nameIsland}}-{{item.parkadeName}}</view>
					<view class="ili_licence">{{item.numberplate}}</view>
					<!-- <view class="ili_date">{{item.enterTime}}</view> -->
					<view class="ili_date">{{item.paymentTime}}</view>
				</view>
			</view>
			<!-- <view class="i_right">-{{item.paymentMoney.toFixed(2)}}</view> -->
			<view class="i_right">-{{item.paymentAmount.toFixed(2)}}</view>
		</view>
		<view class="bottom">
			<view class="btn" @tap="toInvoice">去开票</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				h:uni.getSystemInfoSync().windowHeight - 87,
				mt: uni.getSystemInfoSync().statusBarHeight + 44,
				titleHeader:'开发票',
				h: uni.getSystemInfoSync().windowHeight - 90,
				list:[]
			}
		},
		onLoad(option) {
			if(option.licence){
				this.getDetails(option.licence);
			}
		},
		methods: {
			getDetails(licence){
				// this.$api.get('/travel/wisdom/ParkingRecords/whole?numberplate='+licence).then(res=>{
				this.$api.get('/travel/wisdom/invoicing/invoicing',{openId:JSON.parse(uni.getStorageSync('userInfo')).openId}).then(res=>{
					if(res.data.code===0){
						this.list = res.data.data;
						this.list.forEach((l,i)=>this.$set(this.list[i],'selected',false));
					}else this.$showModal(res.data.msg);
				})
			},
			selectItem(item,index){
				this.$set(this.list[index],'selected',!this.list[index].selected);
			},
			toInvoice(){
				let invoices = this.list.filter(l=>l.selected==true);
				if(invoices.length==0) return this.$showToast('请至少选择一条');
				uni.navigateTo({
					url:'/pagesIndex/parkingService/invoiceSubmit?invoices='+JSON.stringify(invoices)
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page{
		padding: 45rpx 24rpx;
		// padding-top: 130rpx;
		background: #F5F8FA;
		.title{
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #333333;
		}
		.item{
			background: #FFFFFF;
			border-radius: 20rpx;
			margin-top: 20rpx;
			padding: 26rpx 24rpx 20rpx 30rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
			
			.i_left{
				display: flex;
				align-items: center;
				image{
					width: 34rpx;
					height: 34rpx;
				}
				.il_info{
					margin-left: 33rpx;
					&>view{
						font-size: 32rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #333333;
						&.ili_licence{
							margin-top: 4rpx;
						}
						&.ili_date{
							font-size: 28rpx;
							color: #999999;
							margin-top: 20rpx;
						}
					}
				}
			}
			.i_right{
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FE401A;
			}
		}
		
		.bottom{
			width: 100%;
			height: 180rpx;
			position: fixed;
			bottom: 0;
			left: 0;
			z-index: 1;
			background: #fff;
			box-shadow: 0rpx -1rpx 4rpx rgba(0,0,0,0.06);
			.btn{
				width: calc(100% - 60rpx);
				height: 88rpx;
				background: #007A69;
				border-radius: 50rpx;
				line-height: 88rpx;
				text-align: center;
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #FFFFFF;
				letter-spacing: 2rpx;
				margin: 39rpx 30rpx 0;
			}
		}
	}
</style>